package com.mall.file.ceph;

import org.javaswift.joss.model.Container;
import org.javaswift.joss.model.StoredObject;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @description:
 * @author: ljr
 * @time: 2021/9/5 11:15
 */
@Component
public class FileHandler {

    @Resource
    private Container container;

    public void upload(String fileName, byte[] buffer){
        StoredObject object = container.getObject(fileName);
        object.uploadObject(buffer);
    }


    public byte[] downLoad(String fileName){
        StoredObject object = container.getObject(fileName);
        return object.downloadObject();
    }
}
